package com.stm.bi.validator;

import com.stm.api.validation.DataTypeValidator;
import com.stm.framework.core.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AlphaValidator implements DataTypeValidator {
    private static final String REGEX = "^[a-zA-Z]+$";
    
    @Override
    public boolean matches(String exp) {
        return "alpha".equals(exp);
    }

    @Override
    public void validate(String exp, Object data, List<String> messages) {
        if (data == null || !data.toString().matches(REGEX)) {
            String var10001 = String.valueOf(data);
            messages.add(var10001 + "不是有效的字母数据！");
        }
    }

    @Override
    public String getNote(String exp) {
        return StringUtil.isNotEmpty(exp) ? "数据必须仅包含字母；" : "alpha：数据必须仅包含字母；";
    }
}
